

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;
using InfraStructureLayer;

namespace DataLayer
{
	public class datPersonalInstruction
	{
		public datPersonalInstruction()
		{
		}

        public void SelectPersonalInstructionByLanguageId(entPersonalInstruction parEntPersonalInstruction, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", parEntPersonalInstruction.LanguageId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectPersonalInstructionByLanguageId", insDbParamCollection);
            if (insDataTable.Rows.Count > 0)
            {
                if (insDataTable.Rows[0]["PersonalInstructionId"] != DBNull.Value)
                {
                    parEntPersonalInstruction.PersonalInstructionId = Convert.ToInt32(insDataTable.Rows[0]["PersonalInstructionId"]);
                }
                if (insDataTable.Rows[0]["PersonalInstructionTitle"] != DBNull.Value)
                {
                    parEntPersonalInstruction.PersonalInstructionTitle = insDataTable.Rows[0]["PersonalInstructionTitle"].ToString();
                }
                if (insDataTable.Rows[0]["PersonalInstructionBody"] != DBNull.Value)
                {
                    parEntPersonalInstruction.PersonalInstructionBody = insDataTable.Rows[0]["PersonalInstructionBody"].ToString();
                }
                if (insDataTable.Rows[0]["LanguageId"] != DBNull.Value)
                {
                    parEntPersonalInstruction.LanguageId = Convert.ToInt32(insDataTable.Rows[0]["LanguageId"]);
                }
            }
        }
		public void UpdatePersonalInstructionByLanguageId(entPersonalInstruction parEntPersonalInstruction, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", parEntPersonalInstruction.LanguageId);
			insDbParamCollection.Add("@pPersonalInstructionTitle",parEntPersonalInstruction.PersonalInstructionTitle);
			insDbParamCollection.Add("@pPersonalInstructionBody",parEntPersonalInstruction.PersonalInstructionBody);
            parDbConnector.ExecuteNonQuery("UpdatePersonalInstructionByLanguageId", insDbParamCollection);
		}
        public void InsertPersonalInstruction(entPersonalInstruction parEntPersonalInstruction, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pPersonalInstructionTitle", parEntPersonalInstruction.PersonalInstructionTitle);
            insDbParamCollection.Add("@pPersonalInstructionBody", parEntPersonalInstruction.PersonalInstructionBody);
            insDbParamCollection.Add("@pLanguageId", parEntPersonalInstruction.LanguageId);
            insDbParamCollection.AddOutput("@pPersonalInstructionId", DbType.Int32);
            parDbConnector.ExecuteNonQuery("InsertPersonalInstruction", insDbParamCollection);
            parEntPersonalInstruction.PersonalInstructionId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
        }
	}
}